package com.qf.bank.web.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qf.bank.userinfoapi.api.UserInfoApi;
import com.qf.bank.userinfoapi.po.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 乔-wlyjh
 * @date 2019/12/7 10:14
 */
@Slf4j
@RestController
@RequestMapping("/userinfo")
public class UserInfoController {
    @Resource
    private UserInfoApi userInfoApi;
//    @RequestMapping(value = "/", method = RequestMethod.GET)
//    public IPage<UserInfo> page(@RequestParam int current, @RequestParam int size) {
//        IPage<UserInfo> page = userInfoApi.page(current, size);
//        log.info("========page=========="+page);
//        return page;
//    }
    //    查詢所有用戶信息
    @RequestMapping(value = "all/findAll",method = RequestMethod.GET)
    public List findAll(){
        List<UserInfo> list = userInfoApi.findAll();
        return list;
    }
    @RequestMapping(value = "/{userinfoId}",method = RequestMethod.GET)
    public UserInfo findOne(@PathVariable(value = "userinfoId")  int userinfoId){
        return userInfoApi.findOne(userinfoId);
    }

    //    刪除用戶信息
    @RequestMapping(value = "/{userinfoId}",method = RequestMethod.DELETE)
    public boolean deleteById(@PathVariable(value = "userinfoId") int userinfoId){
        boolean byId = userInfoApi.deleteById(userinfoId);
        return byId;
    }
    //xiu修改
    @RequestMapping(value = "/upuserinfo",method = RequestMethod.PUT)
    public boolean update(@RequestBody UserInfo userInfo){
        userInfoApi.update(userInfo);
        return true;
    }
    //增加
    @RequestMapping(value = "/insertuserinfo",method = RequestMethod.POST)
    public UserInfo insert(@RequestBody UserInfo userInfo){
        UserInfo userInfo1 = userInfoApi.insert(userInfo);
        return userInfo1;
    }

}
